package easy

import "strings"

func ToGoatLatin(sentence string) string {
	vowels := map[rune]bool{'a': true, 'e': true, 'i': true, 'o': true, 'u': true, 'A': true, 'E': true, 'I': true, 'O': true, 'U': true}

	words := strings.Split(sentence, " ")
	var result strings.Builder
	for i, word := range words {
		firstChar := rune(word[0])
		if vowels[firstChar] {
			result.WriteString(word + "ma")
		} else {
			result.WriteString(word[1:] + string(firstChar) + "ma")
		}
		for j := 0; j <= i; j++ {
			result.WriteByte('a')
		}
		if i < len(words)-1 {
			result.WriteByte(' ')
		}
	}
	return result.String()
}
